//
//  MyCell.m
//  UI_豆瓣解析
//
//  Created by dllo on 15/9/12.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "MyCell.h"

@implementation MyCell



- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.scrollView = [[UIScrollView alloc]init];
        self.scrollView.minimumZoomScale = 1;
        self.scrollView.maximumZoomScale = 2.f;
        self.scrollView.delegate = self;
        [self.contentView addSubview:_scrollView];
        self.bigPage = [[UILabel alloc]init];
        self.bigPage.backgroundColor = [UIColor colorWithRed:1/255.0 green:1/255.0 blue:1/255.0 alpha:1];
        self.bigPage.textColor = [UIColor whiteColor];
        self.bigPage.textAlignment = NSTextAlignmentCenter;
        self.bigPage.font = [UIFont boldSystemFontOfSize:30];
        self.bigPage.layer.cornerRadius = 100;
        self.bigPage.layer.masksToBounds = YES;
        [self.scrollView addSubview:_bigPage];
        
        self.myImageView = [[UIImageView alloc]init];
        [self.scrollView addSubview:_myImageView];
        
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.scrollView.frame = CGRectMake(0, 0, layoutAttributes.size.width, layoutAttributes.size.height);
    self.myImageView.frame = CGRectMake(0, 0, layoutAttributes.size.width, layoutAttributes.size.height);
    self.bigPage.frame = CGRectMake(self.contentView.bounds.size.width/2-100, self.contentView.bounds.size.height/2-100, 200, 200);

}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    if (scrollView == self.scrollView){
        // 只有小scrollView才允许缩放
        return [scrollView.subviews objectAtIndex:1];
    }else{
        return nil;
    }
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView == _scrollView) {
        int halfX = scrollView.frame.size.width / 2;
//        _pageControl.currentPage = (scrollView.contentOffset.x - halfX) / (scrollView.frame.size.width) + 1;
    }
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    if (scrollView == _scrollView) {
        
         //方法1: 每次减速结束都让scollView所有的scrollView子视图缩放变为1
        
        
        _scrollView.zoomScale = 1.0;
        
        
        
    }
}



@end
